package com.ydy.ewallet.controller;


import com.ydy.ewallet.common.RestResult;
import com.ydy.ewallet.entity.Member;
import com.ydy.ewallet.service.IMemberService;
import com.ydy.ewallet.utils.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author Kephon
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/member")
public class MemberController {

    private final IMemberService srv;

    @Autowired
    public MemberController(IMemberService srv) {
        this.srv = srv;
    }

    @RequestMapping(value = "/info")
    public RestResult info(@RequestParam(value = "id") Long id) {
        ValidationUtils.validateId(id, "id");

        Member member = srv.getById(id);
        ValidationUtils.notNull(member, "会员不存在");

        return RestResult.ok(member);
    }

}
